{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Git 分支管理\n",
    "    分布式版本管理\n",
    "    参考文档：https://git-scm.com/book/en/v2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 恢复丢失的 commit\n",
    "    当 git push 执行结束后没有上传任何记录，git log查找不到commit记录\n",
    "    \n",
    "    ** 一定要 commit **\n",
    "    \n",
    "    * 使用 git reflog 可以查找到所有提交记录\n",
    "    \n",
    "    ```\n",
    "    f823529 HEAD@{0}: pull origin Algorithms: Merge made by the 'recursive' strategy.\n",
    "    8f72b1f HEAD@{1}: merge lostFound: Fast-forward\n",
    "    8be1430 HEAD@{2}: checkout: moving from lostFound to Algorithms\n",
    " \n",
    "    ```\n",
    "    * 然后，reset Head:\n",
    "    git reset --hard 8be1430\n",
    "    \n",
    "    * 新建分支 LostFound,并提交\n",
    "    git branch LostFound\n",
    "    git add --all\n",
    "    git commit -m \"Push lost files\"\n",
    "    git push origin LostFound\n",
    "    \n",
    "    * 切换到原分支，合并代码\n",
    "    git checkout LocalBranch\n",
    "    git merge LostFound LocalBranch\n",
    "    git push origin LocalBranch\n",
    "    \n",
    "    在git 库中查看丢失的文件就找回了。之后清理分支代码就好了。\n",
    "    \n",
    "   **参考：**[git-reflog - Manage reflog information](https://git-scm.com/docs/git-reflog)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Github Flow\n",
    "\n",
    "**Create Branch -> Add commits -> Open a pull request -> Discuss and review code -> Deploy -> Merge (to master)**\n",
    "\n",
    "参考：[Understanding the GitHub flow] (https://guides.github.com/introduction/flow/)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
